﻿using LeanApp.Bll;
using LiveChartsCore;
using LiveChartsCore.Defaults;
using LiveChartsCore.SkiaSharpView;
using System.Collections.Generic;
using System.Windows.Controls;

namespace LeanApp.View
{
    /// <summary>
    /// QuartileCtrl.xaml 的交互逻辑
    /// </summary>
    public partial class QuartileCtrl : UserControl
    {
        /// <summary>
        /// 构造函数
        /// </summary>
        public QuartileCtrl(string title, SpcBll model)
        {
            InitializeComponent();
            _title = title;
            _model = model;
            InitialChart();
        }

        /// <summary>
        /// 初始化图表
        /// </summary>
        private void InitialChart()
        {
            title.Text = _title;
            List<ISeries> series = new List<ISeries>();
            series.Add(
                new BoxSeries<BoxValue>
                {
                    Name = "样本四分位",
                    Values = new BoxValue[]
                    {
                        // max, upper quartile, median, lower quartile, min
                        new BoxValue(_model.Max,_model.UpperQuartile,_model.LowerQuartile,_model.Min,_model.Median),
                    }
                });
            chartSpcQuartile.Series = series;

        }

        /// <summary>
        /// 标题
        /// </summary>
        private string _title;
        /// <summary>
        /// spc实体
        /// </summary>
        private SpcBll _model;
    }
}
